<template>
  <a :href="detailUrl">
    <div class="book_card">
      <div class="thumb" @click.stop="preview">
        <img :src="book.image" alt="图书封面" class="img" mode="aspectFit">
      </div>
      <div class="detail">
        <div class="row">
          <div class="left text-primary">{{book.title}}</div>
          <div>{{book.rate}} <Rate :value='book.rate'></Rate></div>
        </div>
        <div class="row">
          <div class="left">{{book.author}}</div>
          <div class="text-primary">浏览：{{book.count}}</div>
        </div>
        <div class="row">
          <div class="left">{{book.publisher}}</div>
          <div>{{book.user_info.nickName}}</div>
        </div>
      </div>
    </div>
  </a>
</template>
<script>
import Rate from '@/components/Rate'
export default {
  props: ['book'],
  components: {
    Rate
  },
  computed: {
    detailUrl () {
      return '/pages/detail/main?id=' + this.book.id
    }
  },
  methods: {
    preview () {
      wx.previewImage({
        current: this.book.image,
        urls: [this.book.image]
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.book_card {
  padding: 5px;
  margin-top:5px;
  margin-bottom:5px;
  font-size:14px;
  display: flex;
  .thumb {
    width: 90px;
    height: 90px;
    .img {
      max-width: 100%;
      max-height: 100%;
    }
  }
  .detail {
    flex: 1;
    margin-left: 10px;
    .row {
      display: flex;
      justify-content: space-between;
      .left {
        max-width: 180px;
      }
    }
  }
}
</style>
